part of 'component.dart';

class TitleContentItemView extends StatelessWidget {
  const TitleContentItemView({
    Key? key,
    required this.title,
    this.fontSize,
    this.content,
    this.height,
    this.titleStyle,
    this.contentStyle,
    this.backgroundColor,
    this.hasArrow = true,
    this.contentWidget,
    this.margin = EdgeInsets.zero,
    this.padding = EdgeInsets.zero,
    this.onTap,
    this.titleW,
    this.border,
    this.isNeed = false,
    this.mainAxisAlignment = MainAxisAlignment.spaceBetween,
  }) : super(key: key);
  final String title;
  final double? fontSize;
  final String? content;
  final TextStyle? titleStyle;
  final TextStyle? contentStyle;
  final double? height;
  final Color? backgroundColor;
  final EdgeInsets? padding;
  final EdgeInsets? margin;
  final bool? hasArrow;
  final Widget? contentWidget;
  final VoidCallback? onTap;
  final double? titleW;
  final Border? border;
  final bool isNeed;
  final MainAxisAlignment mainAxisAlignment;
  @override
  Widget build(BuildContext context) {
    return InkWell(
        onTap: onTap,
        child: Container(
          margin: margin,
          padding: padding,
          constraints: BoxConstraints(minHeight: height ?? 44.r),
          decoration: BoxDecoration(
            color: backgroundColor,
            border: border,
          ),
          child: Row(
            mainAxisAlignment: mainAxisAlignment,
            children: [
              if (!isNilStr(title))
                SizedBox(
                  width: titleW ?? 150.r,
                  child: Text.rich(
                    TextSpan(
                        text: isNeed ? '*' : '',
                        children: [
                          TextSpan(
                              text: title,
                              style: titleStyle ??
                                  TextStyle(
                                      color: const Color(0xff333333),
                                      fontSize: fontSize ?? 17.sp)),
                        ],
                        style: TextStyle(color: Colors.red, fontSize: 18.sp)),
                  ),
                ),
              Expanded(
                child: Row(
                  mainAxisAlignment: isNilStr(title) ||
                          mainAxisAlignment == MainAxisAlignment.start
                      ? MainAxisAlignment.start
                      : MainAxisAlignment.end,
                  children: [
                    contentWidget ??
                        Flexible(
                          child: Padding(
                            padding: EdgeInsets.symmetric(vertical: 8.r),
                            child: Text(
                              content ?? '',
                              style: contentStyle ??
                                  TextStyle(
                                      color: const Color(0xff999999),
                                      fontSize: 13.sp),
                            ),
                          ),
                        ),
                    Visibility(
                      visible: hasArrow == true,
                      child: Icon(
                        Icons.arrow_forward_ios_rounded,
                        size: 12.r,
                        color: const Color(0xff999999),
                      ),
                    ),
                  ],
                ),
              )
            ],
          ),
        ));
  }
}
